<template>
    <!-- <div class="style: height: 900px;"> -->
    <div class="style: height: 700px;">
        <div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height:600px;left: 0px;top: 55px;bottom:85px;">
        <!-- <div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height:800px;left: 0px;top: 55px;bottom:85px;"> -->
        </div>
    </div>
</template>
<script>
import sheetData from './js/sheetConfig.js'

import staticSheetData from './js/staticSheetData.js'
import dynamicSheetData from './js/dynamicSheetData.js'

export default {
    name: '',
    props: {
        form: {}
    },
    data() {
        return {
            options: {},
            file: ''
        }
    },
    created() {
        this.options = sheetData.configData
        this.options.data = JSON.parse(JSON.stringify(staticSheetData))
        console.log('this.options.data', this.options.data)
        if (this.form && this.form.file) {
            let _sheetData = JSON.parse(this.form.file)
            this.options.data.push(..._sheetData)
        } else {
            this.options.data.push(...dynamicSheetData)
        }
    },
    mounted() {
        let _this = this
        luckysheet.create({
            ...this.options,
            hook: {
                workbookCreateAfter: function() {
                    if (!_this.form.file) {
                        luckysheet.setCellValue(35, 1, {v:_this.form.province}, {order: 0})
                        luckysheet.setCellValue(36, 1, {v:_this.form.annual}, {order: 0})
                        luckysheet.setCellValue(38, 1, {v:_this.form.name}, {order: 0})
                    }
                }
            }
        })
        // this.$nextTick(() => {
        //     if (!this.form.file) {
        //         console.log('------------')
        //         luckysheet.setCellValue(35, 1, {v:'山东'}, {order: 0})
        //     }
        // })
    },
    methods: {
        getData() {
            let data = luckysheet.getAllSheets().slice(0, 4)
            let total = luckysheet.getCellValue(7, 5, {order: 3}).tofixed(2)
            let params = {
                data,
                total
            }
            return params
        }
    },
    destroyed() {
        luckysheet.destroy()
    }
}
</script>
<style lang="scss" scoped></style>